package org.bao.bestmatch.model;

/**
 * definition of matrix.
 * @author baoxiwu<bb@feijiao.info>,Cell&Module,BOE DT
 * @version 0.9.0
 * @since 2010-11-19
 * @license LGPL
 * 
 */
public class Matrix {
	public static final int MATRIX_MAX_DIMENSION_DEFAULT = 256;
	private TFT_CFPair[][] matrix = null;
	private int index = -1;
	
	public Matrix(){
		this.matrix = new TFT_CFPair[Matrix.MATRIX_MAX_DIMENSION_DEFAULT][Matrix.MATRIX_MAX_DIMENSION_DEFAULT];
	}
	
	//given array dimension
	public Matrix(int dimension){
		this.matrix = new TFT_CFPair[dimension][dimension];
	}

	
	public void add(int i, int j,TFT_CFPair pair){
		this.matrix[i][j] = pair;
	}
	
	public TFT_CFPair get(int i, int j){
		return this.matrix[i][j];
	}
	
	public void setSize(int size){
		this.index = size;
	}
	
	public int size(){
		return this.index;
	}
	
	
	//TODO FOR TESTING ONLY,IGNORE THIS IN PRODUCTION.
	public String toString(){
		String sb = "";
		
		for(int i = 0; i < this.index; i++){
			for(int j = 0; j < this.index; j++){
				sb += ("Matrix[" + i + "][" + j + "]:\n" + this.get(i, j).toString() + "\n");
			}
		}
		
		return sb;
	}
}
